package com.kongjs.application.convert;

import com.kongjs.application.model.dto.QueryMenuDTO;
import com.kongjs.application.model.dto.QueryMenuMetaDTO;
import com.kongjs.application.model.dto.SaveMenuDTO;
import com.kongjs.application.model.dto.UpdateMenuDTO;
import com.kongjs.application.model.entity.Menus;
import com.kongjs.application.model.vo.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;

@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE,unmappedSourcePolicy = ReportingPolicy.IGNORE)
public interface MenusConverter {
    @Mappings({
            @Mapping(target = "meta", source = "meta", ignore = true),
            @Mapping(target = "parentId", source = "pid"),
            @Mapping(target = "menuName", source = "name"),
            @Mapping(target = "menuPath", source = "path"),
            @Mapping(target = "menuType", source = "type"),
            @Mapping(target = "menuCode", source = "authCode"),
            @Mapping(target = "menuSort", source = "sort"),
    })
    SaveMenuDTO toDto(SaveMenuVO vo);

    @Mappings({
            @Mapping(target = "meta", source = "meta", ignore = true),
            @Mapping(target = "parentId", source = "pid"),
            @Mapping(target = "menuName", source = "name"),
            @Mapping(target = "menuPath", source = "path"),
            @Mapping(target = "menuType", source = "type"),
            @Mapping(target = "menuCode", source = "authCode"),
            @Mapping(target = "menuSort", source = "sort"),
    })
    UpdateMenuDTO toDto(UpdateMenuVO vo);
    @Mappings({
            @Mapping(target = "meta", source = "meta", ignore = true)
    })
    Menus toEntity(SaveMenuDTO dto);
    @Mappings({
            @Mapping(target = "meta", source = "meta", ignore = true)
    })
    Menus toEntity(UpdateMenuDTO dto);
    @Mappings({
            @Mapping(target = "meta", source = "meta", ignore = true)
    })
    QueryMenuDTO toDto(Menus entity);

    @Mappings({
            @Mapping(target = "meta", source = "meta", ignore = true),
            @Mapping(target = "pid", source = "parentId"),
            @Mapping(target = "name", source = "menuName"),
            @Mapping(target = "path", source = "menuPath"),
            @Mapping(target = "type", source = "menuType"),
            @Mapping(target = "authCode", source = "menuCode"),
            @Mapping(target = "sort", source = "menuSort"),
    })
    QueryMenuVO toVo(QueryMenuDTO dto);

    QueryMenuMetaVO toVo(QueryMenuMetaDTO dto);
}


